package com.lou.springboot.controller;

import com.lou.springboot.common.PageResult;
import com.lou.springboot.common.ResultVO;
import com.lou.springboot.common.ResultVOUtil;
import com.lou.springboot.entity.AdminUser;
import com.lou.springboot.enums.ResultEnum;
import com.lou.springboot.service.AdminUserService;
import com.lou.springboot.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/adminusers")
public class AdminUserController {

    @Autowired
    private AdminUserService adminUserService;

    @GetMapping("/list")
    public ResultVO list(@RequestParam Map<String, Object> paramMap){
        if (StringUtils.isEmpty(paramMap.get("page"))
            || StringUtils.isEmpty(paramMap.get("limit"))) {
            return ResultVOUtil.error(ResultEnum.PARAM_ERROR);
        }
        PageUtil pageUtil = new PageUtil(paramMap);
        PageResult pageResult = adminUserService.getAdminUserPage(pageUtil);
        return ResultVOUtil.success(pageResult);
    }
}
